<?php
	/*
	 * update article slug title .
	 *
	*/
	
	
	error_reporting(E_ALL);
	require_once('config/constant.php');
	require_once(DAEMONE_HOME.'/config/amazon.php');
	require_once(DAEMONE_HOME.'/lib/lib_database.php');
	require_once(DAEMONE_HOME.'/lib/lib_rss_database.php');


	
	execute_query('update products set slug_product_title=NUll');
	set_time_limit(3600);
	$limit = 10000;
	//update products set slug_product_title=NUll;
	while (TRUE)
	{
		$result = execute_query("select product_id, product_title from products where slug_product_title IS NULL limit $limit");

		if($result === FALSE) 
		{
			echo  mysql_error();
		}

		
		if(mysql_num_rows($result) == 0)
		{
			echo "No more records /n";
			exit;
		}
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$result_1 = execute_query('update products set slug_product_title=\''. strtolower(preg_replace('/[-]+/', '-', preg_replace('/[\W]/', '-', $row['product_title']))) .'\' where product_id='.$row['product_id']);
			if($result_1 === FALSE) 
			{
				echo mysql_error(), "\r\n";
			}
			echo 'product_id=', $row['product_id'], "\r\n";
		}
		
	}
	exit;
?>
